package com.plian.system.service.pm.listedcompany.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.plian.Tools.CollectionUtil;
import com.plian.system.entity.pm.listedcompany.EarningsExecuteDetail;
import com.plian.system.mapper.pm.listedcompany.EarningsExecuteDetailMapper;
import com.plian.system.mybatis.base.BaseServiceImpl;
import com.plian.system.service.pm.listedcompany.IEarningsExecuteDetailService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description: TODO
 * @Author: Take-off
 * @Date: 2023/2/28 7:55 PM
 * @Param
 * @return
 * @Version: 1.0
 **/

@Service
@AllArgsConstructor
public class EarningsExecuteDetailServiceImpl extends BaseServiceImpl<EarningsExecuteDetailMapper, EarningsExecuteDetail> implements IEarningsExecuteDetailService {

    @Override
    public boolean deleteByParentId(List<Long> ids) {
        LambdaQueryWrapper<EarningsExecuteDetail> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(EarningsExecuteDetail::getBaseId, ids);
        List<EarningsExecuteDetail> earningsExecuteDetails = list(queryWrapper);
        if (CollectionUtil.isNotEmpty(earningsExecuteDetails)){
            return deleteLogic(earningsExecuteDetails.stream().map(EarningsExecuteDetail::getId).collect(Collectors.toList()));
        }
        return true;
    }
}
